package com.itheima.interceptor;
import com.itheima.interceptor.SoulInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.Arrays;
import java.util.List;

//@Configuration
public class SoulConfig implements WebMvcConfigurer {


    private static final List<String> EXCLUDE_PATH = Arrays.asList("/", "css/**", "js/**", "element-ui/**","images/**", "list-css/**","/login.html","/newAdmin/verification","/newAdmin/login");


    @Autowired
    private SoulInterceptor tokenInterceptor;


    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/static/**");
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(tokenInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns(EXCLUDE_PATH);
    }
}